<?php


namespace app\api\model\User;



use think\facade\Db;
use think\Model;

class UserLevelModel extends Model
{

    /**
     * 数据表名
     * @var string
     */
    protected $name = "user_level";

    /**
     * 根据条件查询单条数据
     * @param $where
     * @return mixed
     * @throws
     */
    public static function getUserLevelWhere($where,$filed="*")
    {
        $level = Db::name("user_level")->field($filed)->where($where)->find();
        return $level;
    }

    /**
     * 根据条件查询多条数据
     * @param $where
     * @return mixed
     * @throws
     */
    public static function getUserLevelWhereMore($where)
    {
        $list = Db::name("user_level")->where($where)->select()->toArray();
        return $list;
    }

    /**
     * 统计总数
     * @param $where
     * @return int
     */
    public static function getUserLevelCountWhere($where)
    {
        $count = Db::name("user_level")->where($where)->count();
        return $count;
    }

    /**
     * 分页查询
     * @param $page
     * @param $limit
     * @param $where
     * @return mixed
     * @throws
     */
    public static function getUserLevelListWhere($page,$limit,$where = [],$field="*")
    {
        $start = ceil(($page-1)*$limit);
        $list = Db::name('user_level')->field($field)->where($where)->limit($start,$limit)->select()->toArray();
        return $list;
    }

}
